<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>个人中心</title>
</head>
<body>
	<?php
	require_once ".\system\dbConn.php";
    require_once('head.php');
		$user=$_GET["user"];
		$sql0="select * from demand where ischeck=0 and uploadusers='$user'";//我提出的问题
		$result0=mysqli_query($link,$sql0);
//单条记录
		//var_dump($result);

		$sql1="select * from goods where uploaduser='$user'";//我发布的商品
		$result1=mysqli_query($link,$sql1);

		//var_dump($result1);

		$sql2="select * from entry join activity on entry.aname=activity.aname where uname='$user'";//我报名的活动
		$result2=mysqli_query($link,$sql2);

		//var_dump($result2);

		$sql3="select * from demand join accepter on demand.name=accepter.dname where accepter='$user'";//我接收的问题
		$result3=mysqli_query($link,$sql3);



		$sql4="select * from users where username='$user'";
		$result4=mysqli_query($link,$sql4);

		$row4=mysqli_fetch_assoc($result4);


		
		// $num2=mysql_fetch_assoc($result2);
		// $num2=$tempRow2["count"];
		// if ($num2==0) {
		// 	echo "没有找到符合条件的任务";
		// 	exit;
		// }
		// $num0=mysql_fetch_assoc($result0);
		// $num3=$tempRow3["count"];
		// if ($num3==0) {
		// 	echo "没有找到符合条件的任务";
		// 	exit;
		// }
		// $num0=mysql_fetch_assoc($result0);
		// $num4=$tempRow4["count"];
		// if ($num4==0) {
		// 	echo "没有找到符合条件的任务";
		// 	exit;
		// }

	?>

	<div class="" style="width: 75%;background-color:#EEE9BF;margin-left: 250px;background-image:url(./assets/personal.png);background-size:100%" >
		<div class="media">
		  <img class="align-self-start mr-3" src="./images/<?php echo $row4["pic"];?>" alt="Generic placeholder image" width="100" height="100" style="margin-top: 120px;margin-left: 45px;margin-bottom: 30px" >
		  <div class="media-body" style="color:#ffffff;margin-top: 120px;margin-left: 45px;margin-right: 45px;margin-bottom: 30px">
		    <h5 class="mt-0" style="color:#ffffff;"><?php echo $row4["username"];?></h5>
		  </div>
		</div>
	</div>


	<div style="width: 75%;background-color:#E0EEEE;margin-left: 250px">
		<ul class="nav nav-tabs" id="myTab">
		  <li class="nav-item">
		    <a class="nav-link active" href="#home">我提出的任务</a>
		  </li>
		  <li class="nav-item">
		    <a class="nav-link" href="#demand">我接受的任务</a>
		  </li>
		  <li class="nav-item">
		    <a class="nav-link" href="#goods">我发布的商品</a>
		  </li>
		  <li class="nav-item">
		    <a class="nav-link" href="#activity">我报名的活动</a>
		  </li>
		</ul>
	</div>
	<div id="myTabContent" class="tab-content">
	    <div class="tab-pane fade in active" id="home">
	    	<?php 					
	    		$num0=mysql_num_rows($result0);
				if ($num0==0) {
					echo "<p style='width: 75%;margin-left: 250px'>没有找到符合条件的任务</p>";
					}else{
			 ?>
				<table class="table table-hover" style="width: 75%;margin-left: 250px" >	
									<thead class="thead-dark">
										<th>序号</th>
										<th>任务名称</th>
										<th>任务类型</th>
										<th>时限</th>
										<th>报酬</th>
										<th>发布时间</th>
										<th>发布人</th>
									 </thead>

								<?php

								$i=0;
								while ($row0=mysql_fetch_assoc($result0)) {	
									$i++;
								?>
									<tr>
										<td><?php echo $i; ?></td>
										<td><?php echo $row0["name"]; ?></td>
										<td><?php 
											if ($row0["type"] == 0) {
											 	echo "寻找失物";
											 } elseif ($row0["type"] == 1) {
											 	echo "物品借用";
											 }elseif ($row0["type"] == 2) {
											 	echo "疑惑解答";
											 }elseif ($row0["type"] == 3) {
											 	echo "电脑修理";
											 }
										?></td>
										<td><?php 
											if ($row0["time"] == 0) {
										 	echo "5min之内";
										 } elseif ($row0["time"] == 1) {
										 	echo "5~15min";
										 }elseif ($row0["time"] == 2) {
										 	echo "15~30min";
										 }elseif ($row0["time"] == 3) {
										 	echo "一天以内";
										 }elseif ($row0["time"] == 4) {
										 	echo "一周以内";
										 }
										 ?></td>
										<td><?php echo $row0["money"]."元"; ?></td>
										<td><?php echo $row0["uploaddate"]; ?></td>
										<td><?php echo $row0["uploadusers"]; ?></td>
									</tr>
								<?php
								}
							?>
						</table>
						<?php } ?>
	    </div>
	    <div class="tab-pane fade" id="demand">
	    	<?php 					
	    		$num3=mysql_num_rows($result3);
				if ($num3==0) {
					echo "<p style='width: 75%;margin-left: 250px'>没有找到符合条件的任务</p>";
					}else{
			 ?>
	       <table class="table table-hover" style="width: 75%;margin-left: 250px" >	
									<thead class="thead-dark">
										<th>序号</th>
										<th>任务名称</th>
										<th>任务类型</th>
										<th>时限</th>
										<th>报酬</th>
										<th>发布时间</th>
										<th>发布人</th>
									 </thead>

								<?php
								$i=0;
								while ($row3=mysql_fetch_assoc($result3)) {	

									$i++;
								?>
									<tr>
										<td><?php echo $i; ?></td>
										<td><?php echo $row3["name"]; ?></td>
										<td><?php 
											if ($row3["type"] == 0) {
											 	echo "寻找失物";
											 } elseif ($row3["type"] == 1) {
											 	echo "物品借用";
											 }elseif ($row3["type"] == 2) {
											 	echo "疑惑解答";
											 }elseif ($row3["type"] == 3) {
											 	echo "电脑修理";
											 }
										?></td>
										<td><?php 
											if ($row3["time"] == 0) {
										 	echo "5min之内";
										 } elseif ($row3["time"] == 1) {
										 	echo "5~15min";
										 }elseif ($row3["time"] == 2) {
										 	echo "15~30min";
										 }elseif ($row3["time"] == 3) {
										 	echo "一天以内";
										 }elseif ($row3["time"] == 4) {
										 	echo "一周以内";
										 }
										 ?></td>
										<td><?php echo $row3["money"]."元"; ?></td>
										<td><?php echo $row3["uploaddate"]; ?></td>
										<td><?php echo $row3["uploadusers"]; ?></td>
									</tr>
								<?php
								}
							?>
						</table>
					<?php } ?>
	    </div>
	    <div class="tab-pane fade" id="goods">
	    	<?php 					
	    		$num1=mysql_num_rows($result1);
				if ($num1==0) {
					echo "<p style='width: 75%;margin-left: 250px'>没有找到符合条件的商品</p>";
					}else{
			 ?>
	        <ul class="list-inline row text-center" style="width: 75%;margin-left: 250px">


                    <?php 
                    while ($row1=mysql_fetch_assoc($result1)) {
                       ?>
                         <div class="row" style="margin-left: 30px;background-color:#ffffff;padding:10px;margin-top: 20px">
										  <div class="col-sm-2 col-md-12">
										    <div class="thumbnail">
										       <img src="./images/<?php echo $row1["pic"];?>" class="img-responsive" alt="Responsive image"  width="140" height="180" title="介绍：<?php echo $row1["detial"]; ?>">

										      <div class="caption" style="margin-top: 10px">
										        <h6><a href="#"><?php echo $row1["gname"]; ?></a></h6>
										        <p style="font-size: 10px"><?php echo $row1["time"]; ?>&nbsp&nbsp<?php echo "￥".$row1["price"]."元 "; ?></p>
										        <p style="font-size: 13px"><?php echo $row1["uploaduser"]; ?>:&nbsp&nbsp<?php echo $row1["phone"]; ?></p>
										      </div>
										    </div>
										  </div>
										</div>
                       <?php 
                    }
                     ?>

                    </ul>
                <?php } ?>
	    </div>
	    <div class="tab-pane fade" id="activity">
	    	<?php 					
	    		$num2=mysql_num_rows($result2);
				if ($num2==0) {
					echo "<p style='width: 75%;margin-left: 250px'>没有报名的活动</p>";
					}else{
			 ?>
	       <div style="width: 75%;margin:20px auto;margin-left: 250px">
	<?php
		$index=0;
		while ($row2=mysql_fetch_assoc($result2)) {	
		?>
		<div class="card-hidden" id="card-hidden-<?php echo $index;?>" style="margin-top:70px;margin-bottom:10px;background: #ffffff;border-radius:20px;box-shadow:10px 10px 5px #C7C7C7;border-radius:20px;">
		 <div class="col-md-12 col-sm-12">
	    	<div class="panel panel-default" >
	    		<br>
			  <div class="panel-heading" align="center" style="margin-top: 15px"><h4><?php echo $row2["aname"]; ?></h4></div>
			  <div class="panel-body" >
			    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<?php echo $row2["adetial"]; ?>
			  </div>
			  <br>
			  <div style="float: right;"><button type="button" class="btn-more" id="btn-more-<?php echo $index;?>">显示更多</button></div>
			   <br>
			  <br>
			</div>
		 </div>
		</div>

		<div class="card-shown" id="card-shown-<?php echo $index;?>" style="margin-top:70px;margin-bottom:10px;background: #ffffff;border-radius:20px;box-shadow:10px 10px 5px #C7C7C7;border-radius:20px;">
		 <div class="col-md-12 col-sm-12">
	    	<div class="panel panel-default" >
	    		<br>
			  <div class="panel-heading" align="center"  style="margin-top: 15px"><h4><?php echo $row2["aname"]; ?></h4></div>
			  <div class="panel-body1" >
			    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<?php echo $row2["adetial"]; ?>
			  </div>
			  <br>
			</div>
		 </div>
		</div>

		<?php
		$index=$index+1;
		}
		
		?>
	    </div>
	<?php } ?>
	</div>
<script>
	$(function () {
        $('#myTab li:eq(1) a').tab('show');
    });
    $('#myTab a').click(function (e) {
	  e.preventDefault()
	  $(this).tab('show')
	});


	$(document).ready(function(e) {
		$(".card-hidden").show().addClass("show");
             // 执行隐藏
    $(".card-shown").hide().removeClass("show");
    $("button[id^='btn-more-']").click(function(e) {
				const index = e.target.id.replace("btn-more-","");
        if( $("#card-hidden-"+index).hasClass("show") ){
            // 执行隐藏
            $("#card-hidden-"+index).hide().removeClass("show");
            //显示
            $("#card-shown-"+index).show().addClass("show");
            // 其他
        }else{
            // 显示
            $("#card-hidden-"+index).show().addClass("show");
             // 执行隐藏
             $("#card-shown-"+index).hide().removeClass("show");
        }
    });
});
</script>

<style>
	 .panel-body{
        display: -webkit-box;
        overflow: hidden;
        white-space: normal !important;
        text-overflow: ellipsis;
        word-wrap: break-word;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
    }
</style>
</body>
</html>